<!-- INCLUDE sv_overall_header.html -->


<SCRIPT>
var form_submitted = false;

function validate()
{	
	if( form_submitted == true )
	{
		return false;
  	}
  	
	var corp_id = get_selected_corp_id();
	
	if (corp_id == '')
	{
		// it will be empty if there is only one radio. 
		corp_id = 	document.forms['sell_form'].elements['corp_id'].value;
	}

	var number_id = corp_id + "_number";
	var	number_to_sell = parseInt(document.getElementById(number_id).value);
	var number_id = corp_id + "_sellable_number";
	var	number_sellable = parseInt(document.forms['sell_form'].elements[number_id].value);

	if (number_to_sell > number_sellable)
	{
		alert("{L_SV_NOT_ENOUGH_SHARE_SELL}");
		return false;
	}
	
	market_price = document.getElementById('request_price_radio_0').checked;
	//alert(market_price);

	if (market_price)
	{
		document.forms['sell_form'].elements['request_price'].value = 0;		
	}
	else
	{
		request_price = parseFloat(document.forms['sell_form'].elements['request_price_text'].value);
				
		if (request_price > 0 && request_price < 99999)
			document.forms['sell_form'].elements['request_price'].value = request_price;
		else
		{
			alert('{L_SV_REQUEST_PRICE_NOT_OK}');
			return false;
		}
	}

	form_submitted = true;
	
	return true;
}

function get_selected_corp_id()
{
	var	radio_corp_id = document.forms['sell_form'].elements['corp_id'];

	for (i = 0; i < radio_corp_id.length; ++i)
	{
		if (radio_corp_id.item(i).checked == true)
			return radio_corp_id.item(i).value;
	}

	return '';
}

function number_change(number)
{
	var postfix		= "_number";
	var number_id	= number.id;
	var to			= number_id.length - postfix.length;	
	var corp_id		= number_id.substring(0, to);

	var	radio_corp_id = document.forms['sell_form'].elements['corp_id'];

	for (i = 0; i < radio_corp_id.length; ++i)
	{
		if (radio_corp_id.item(i).value == corp_id)
			radio_corp_id.item(i).checked = true;			
	}
}


function ShowContent(d) 
{
	document.getElementById(d).style.display = "block";
}
function HideContent(d) 
{
	document.getElementById(d).style.display = "none";
}
	
function ShowRequestPriceDiv()
{
	ShowContent('request_price_div');
	HideContent('market_price_div');
	document.getElementById("request_price_radio_1").checked = true;
	document.getElementById("request_price_text").focus();
}
    
function onPriceTextChange()
{
	document.getElementById("request_price_radio_1").checked = true;
}
</SCRIPT>

<!-- IF not S_USER_LOGGED_IN and not S_IS_BOT -->
	<form method="post" action="{S_LOGIN_ACTION}" class="headerspace">
	<h3><a href="{U_LOGIN_LOGOUT}">{L_LOGIN_LOGOUT}</a><!-- IF S_REGISTER_ENABLED -->&nbsp; &bull; &nbsp;<a href="{U_REGISTER}">{L_REGISTER}</a><!-- ENDIF --></h3>
		<fieldset class="quick-login">
			<label for="username">{L_USERNAME}:</label>&nbsp;<input type="text" name="username" id="username" size="10" class="inputbox" title="{L_USERNAME}" />
			<label for="password">{L_PASSWORD}:</label>&nbsp;<input type="password" name="password" id="password" size="10" class="inputbox" title="{L_PASSWORD}" />
			<!-- IF S_AUTOLOGIN_ENABLED -->
				| <label for="autologin">{L_LOG_ME_IN} <input type="checkbox" name="autologin" id="autologin" /></label>
			<!-- ENDIF -->
			<input type="submit" name="login" value="{L_LOGIN}" class="button2" />
			{S_LOGIN_REDIRECT}
		</fieldset>
	</form>
<!-- ENDIF -->


<!-- IF S_HOLDING_STOCK_LIST  -->
<div class="panel" > 
	<div class="inner"><span class="corners-top"><span></span></span> 
	<h2>
		<!-- IF S_OFF_HOUR_TRADING -->
		{L_SV_SELL_OFF_HOUR}
		<!-- ELSE -->
		{L_SV_SELL} &nbsp
		<!-- ENDIF -->
		<img title="{L_SV_SELL_PAGE_INFO}" src="{T_IMAGES_PATH}icons/smile/info.gif" alt="info" /> 
	</h2> 
	</div>
	<!-- IF S_OFF_HOUR_TRADING -->
		<p>({L_SV_SELL_OFF_HOUR_TIP})</p>
		<form name="sell_form" method="post" action="{S_OFF_HOUR_TRADING_ACTION}" onsubmit="return validate();">
			<input type="hidden" name="off_hour_trading" value="1" > 
	<!-- ELSE -->
		<form name="sell_form" method="post" action="{S_SELL_ACTION}" onsubmit="return validate();">
		
			<input type="hidden" name="request_price" id="request_price" value="0">
	<!-- ENDIF -->
	
		
	<table border="0" cellpadding="5" cellspacing="5">
		<tr>
			<!-- IF S_OFF_HOUR_TRADING -->
				<td title="{L_SV_SELL_PAGE_TIP_SELECTION}"><p> </p></td>				
				<td title="{L_SV_COMMON_TIP_CORP_ID}"><p>{L_SV_CORP_NAME}</p></td>
				<td title="{L_SV_SELL_PAGE_TIP_HOLDING_SHARE_NUMBER}" align="center"><p>{L_SV_HOLDING_SHARE_NUMBER}</p></td>				
				<td title="{L_SV_SELL_PAGE_TIP_COST}" align="center"><p>{L_SV_COST}</p></td>
				<td title="{L_SV_SELL_PAGE_TIP_REFERED_PRICE}" align="center"><p>{L_SV_REFERED_PRICE}</p></td>				
			<!-- ELSE -->
				<td title="{L_SV_SELL_PAGE_TIP_SELECTION}"><p> </p></td>
				<td title="{L_SV_SELL_PAGE_TIP_SELECTION}"><p> </p></td>
				<td title="{L_SV_COMMON_TIP_CORP_ID}"><p>{L_SV_CORP_NAME}</p></td>
				<td title="{L_SV_SELL_PAGE_TIP_SEELABLE_NUMBER}" align="center"><p>{L_SV_SEELABLE_NUMBER}</p></td>
				<td title="{L_SV_SELL_PAGE_TIP_HOLDING_NUMBER}" align="center"><p>{L_SV_HOLDING_NUMBER}</p></td>
				<td title="{L_SV_SELL_PAGE_TIP_TO_SELL_NUMBER}" align="center"><p>{L_SV_TO_SELL_NUMBER}</p></td>
				<td title="{L_SV_SELL_PAGE_TIP_COST}" align="center"><p>{L_SV_COST}</p></td>
				<td title="{L_SV_SELL_PAGE_TIP_REFERED_PRICE}" align="center"><p>{L_SV_REFERED_PRICE}</p></td>				
			<!-- ENDIF -->
		</tr>
		
		<!-- BEGIN holding_stock_list -->
		<tr>
			<!-- IF S_OFF_HOUR_TRADING -->
			
				<!-- IF holding_stock_list.CANNOT_SELL  -->
					<td title="{L_SV_SELL_PAGE_TIP_SELECTION}" ><p> <input type="radio" name="corp_id" value="{holding_stock_list.CORP_ID}" disabled="disabled"> </p></td>
				<!-- ELSE -->
					<td title="{L_SV_SELL_PAGE_TIP_SELECTION}" ><p> <input type="radio" name="corp_id" value="{holding_stock_list.CORP_ID}" checked> </p></td>
				<!-- ENDIF -->
				
				<td title="{L_SV_COMMON_TIP_CORP_ID}"><p>{holding_stock_list.CORP_NAME}({holding_stock_list.CORP_ID})</p></td>
				
				
				<td title="{L_SV_SELL_PAGE_TIP_HOLDING_SHARE_NUMBER}" align="center"><p>{holding_stock_list.HOLDING_NUMBER}</p></td>
				<input type="hidden" name="{holding_stock_list.CORP_ID}_share" id="{holding_stock_list.CORP_ID}_share" value="{holding_stock_list.HOLDING_NUMBER}">
				
				<td title="{L_SV_SELL_PAGE_TIP_COST}" align="center"><p>{holding_stock_list.COST}</p></td>
				<td title="{L_SV_SELL_PAGE_TIP_REFERED_PRICE}" align="center"><p>{holding_stock_list.REFERED_PRICE}</p></td>	
				
			<!-- ELSE -->
			
				<!-- IF holding_stock_list.CANNOT_SELL  -->
					<td title="{L_SV_SELL_PAGE_TIP_SELECTION}" ><p> <input type="radio" name="corp_id" value="{holding_stock_list.CORP_ID}" disabled="disabled"> </p></td>
					<td title="{L_SV_SELL_PAGE_TIP_SELECTION}" ><p> <input type="text" name="{holding_stock_list.CORP_ID}_number" size="10" value="0" disabled="disabled"> </p></td>
				<!-- ELSE -->
					<td title="{L_SV_SELL_PAGE_TIP_SELECTION}" ><p> <input type="radio" name="corp_id" value="{holding_stock_list.CORP_ID}" checked> </p></td>
					
					<td title="{L_SV_SELL_PAGE_TIP_SELECTION}" ><p>
						<select name="{holding_stock_list.CORP_ID}_number" id="{holding_stock_list.CORP_ID}_number" class="row2" title="{L_SV_NUMBER}" onchange="number_change(this);">
							<OPTION VALUE="1" SELECTED>1 </OPTION>
							<!-- IF holding_stock_list.SELLABLE_NUMBER >= 2  --> <OPTION VALUE="2"> 2 </OPTION> <!-- ENDIF -->
							<!-- IF holding_stock_list.SELLABLE_NUMBER >= 3  --> <OPTION VALUE="3"> 3 </OPTION> <!-- ENDIF -->
							<!-- IF holding_stock_list.SELLABLE_NUMBER >= 4  --> <OPTION VALUE="4"> 4 </OPTION> <!-- ENDIF -->
							<!-- IF holding_stock_list.SELLABLE_NUMBER >= 5  --> <OPTION VALUE="5"> 5 </OPTION> <!-- ENDIF -->
							<!-- IF holding_stock_list.SELLABLE_NUMBER >= 10  --> <OPTION VALUE="10"> 10 </OPTION> <!-- ENDIF -->
							<!-- IF holding_stock_list.SELLABLE_NUMBER >= 20  --> <OPTION VALUE="20"> 20 </OPTION> <!-- ENDIF -->					
							<!-- IF holding_stock_list.SELLABLE_NUMBER >= 50  --> <OPTION VALUE="50"> 50 </OPTION> <!-- ENDIF -->					
							<!-- IF holding_stock_list.SELLABLE_NUMBER >= 100  --> <OPTION VALUE="100"> 100 </OPTION> <!-- ENDIF -->
								
								
							<!-- IF holding_stock_list.SELLABLE_NUMBER > 5 -->
							<!-- IF holding_stock_list.SELLABLE_NUMBER != 10 -->
							<!-- IF holding_stock_list.SELLABLE_NUMBER != 20 -->
							<!-- IF holding_stock_list.SELLABLE_NUMBER != 50 -->
							<!-- IF holding_stock_list.SELLABLE_NUMBER != 100 -->
							<OPTION VALUE="{holding_stock_list.SELLABLE_NUMBER}"> {holding_stock_list.SELLABLE_NUMBER} </OPTION> 
							<!-- ENDIF --> <!-- ENDIF --> <!-- ENDIF --> <!-- ENDIF --> <!-- ENDIF -->
													
						</select>
					</p></td>
				<!-- ENDIF -->
				
				<td title="{L_SV_COMMON_TIP_CORP_ID}"><p>{holding_stock_list.CORP_NAME}({holding_stock_list.CORP_ID})</p></td>
			
				<td title="{L_SV_SELL_PAGE_TIP_SEELABLE_NUMBER}" align="center"><p>{holding_stock_list.SELLABLE_NUMBER} 
					<input type="hidden" name="{holding_stock_list.CORP_ID}_sellable_number" size="10" value="{holding_stock_list.SELLABLE_NUMBER}">
				</p></td>
				<td title="{L_SV_SELL_PAGE_TIP_HOLDING_NUMBER}" align="center"><p>{holding_stock_list.HOLDING_NUMBER}</p></td>
				<td title="{L_SV_SELL_PAGE_TIP_TO_SELL_NUMBER}" align="center"><p>{holding_stock_list.TO_SELLNUMBER}</p></td>
			
				<td title="{L_SV_SELL_PAGE_TIP_COST}" align="center"><p>{holding_stock_list.COST}</p></td>
				<td title="{L_SV_SELL_PAGE_TIP_REFERED_PRICE}" align="center"><p>{holding_stock_list.REFERED_PRICE}</p></td>	
			
			<!-- ENDIF -->
		</tr>
		<!-- END holding_stock_list -->

		<tr> <td><p> </p></td> </tr>
	</table>
	
	
	<!-- IF ! S_OFF_HOUR_TRADING -->
	<div id="market_price_div" style="display:block;">
	<table width="40%">			
		<tr title="{L_SV_REQUEST_PRICE_TIP_NOTE}"> 
			<td ><label ><p>{L_SV_REQUEST_PRICE}:</p></label> </td> 
			<td ><label > <p> {L_SV_MARKET_PRICE}  <a href="javascript:ShowRequestPriceDiv();">
					({L_SV_SPECIFY_PRICE_LINK})
				</a> </p>
			</td> 			
		</tr>		
	</table>    			
	</div>		
	    
	<div id="request_price_div" style="display:none;">
	<table>			
		<tr title="{L_SV_REQUEST_PRICE_TIP_NOTE}"> 
			<td ><label ><p>{L_SV_REQUEST_PRICE}:  </p></label> </td> 
			<td >  <input type="radio" name="request_price_radio" id="request_price_radio_0" value="0" checked> {L_SV_MARKET_PRICE}  </td>
			
		</tr>
		<tr title="{L_SV_REQUEST_PRICE_TIP_NOTE}"> 
			<td >  </td> 
			<td >  <input type="radio" name="request_price_radio" id="request_price_radio_1" value="1" > {L_SV_SPECIFY_PRICE}: 
			<input type="text" name="request_price_text" id="request_price_text" class="inputbox" title="{L_SV_REQUEST_PRICE_TIP_NOTE}" onchange="onPriceTextChange();" />
			 </td>	    
		</tr>
	</table>
	</div>
	<!-- ENDIF -->    
	    
	<table width="40%">		
		<tr title="{L_SV_SELL_PAGE_TIP_NOTE}"> 
			<td width="40"><label for="note"><p>{L_SV_NOTE}:</p></label> </td> 
			<td  aligh="left"> <input type="textarea" name="note" id="note" size="200" class="inputbox" title="{L_SV_SELL_PAGE_TIP_NOTE}" /></p></td>
		</tr>
		<tr>
			<td><p> <input type="submit" name="login" value="{L_SV_SEND}" class="button2" /></p></td>
		</tr>
	</table>
	
	</form>
</div>
<!-- ELSE -->
<div class="panel" > 
	<div class="inner"><span class="corners-top"><span></span></span> 
	<h2>{L_SV_SELL}</h2> 
	</div>
	<h3>{L_SV_NO_HOLDING_STOCK}</h3>
</div>
<!-- ENDIF -->

<!-- IF S_ALLOW_OFF_HOUR_TRADING -->
<p> <a href="{S_OFF_HOUR_TRADING_LINK}"> {L_SV_LINK_FOR_SELL_OFF_HOUR} </a></p>
<!-- ENDIF -->


<!-- INCLUDE to_sell_delegation_list.html -->





<!-- INCLUDE sv_overall_footer.html -->